class Solution {
public:
    bool canJump(vector<int>& nums) {
      int p = 0;
      for(int i = 0;i < nums.size();i++){
        if(i <= p){
          p = max(p,nums[i] + i);
        }
      }
      return p >= nums.size() - 1? true : false;
    }
};
